#include "atomic_op_asm.h"

ENTRY_NP(_atomic_swap_64)
	mov	x4, x0
1:	ldxr	x0, [x4]
	stxr	w3, x1, [x4]
	cbnz	w3, 1b
	dmb	st
	ret
END(_atomic_swap_64)

ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_64)
STRONG_ALIAS(__sync_lock_test_and_set_8,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64)

ENTRY_NP(__sync_lock_release_8)
	stlr	xzr, [x0]
	ret
END(__sync_lock_release_8)
